package leetcode.editor.cn.q1_300.q100;

/**
 * 自己的办法就 用 hashmap 或者排序，所以直接看答案了
 *
 * @author qidi
 * @date 2022-01-14 14:30:27
 */
class Q0137_SingleNumberIi {

    //leetcode submit region begin(Prohibit modification and deletion)
    class Solution {
        public int singleNumber(int[] nums) {
            int ans = 0;
            for (int i = 0; i < 32; i++) {
                int total = 0;
                for (int num : nums) {
                    total += (num >> i & 1);
                }
                if (total % 3 != 0) ans |= 1 << i;
            }
            return ans;
        }
    }
    //leetcode submit region end(Prohibit modification and deletion)


    public static void main(String[] args) {
        Solution solution = new Q0137_SingleNumberIi().new Solution();
    }
}